package com.dbqn.zhao.service.impl;

import com.dbqn.zhao.entiy.User;
import com.dbqn.zhao.service.BaseService;

import java.text.BreakIterator;
import java.util.List;
import java.util.Scanner;

public class MailImpl implements BaseService {
    @Override
    public List excute(List list) {
        User user=new User();
        Scanner sc=new Scanner(System.in);

        System.out.println("*********我要寄件*********");

        for(;;){
            System.out.println("请选择寄件方式:1.上门取件 2.服务点自寄");
            int xzx=sc.nextInt();

            if(xzx==1){
                user.setJijianfs("上门取件");
                break;
            }else if(xzx==2){
                user.setJijianfs("服务店自取");
                break;
            }else{
                System.out.println("请输入正确选项！");
            }
        }

     for(;;){

         System.out.println("请输入取件人信息：");
         String shuru=sc.next();
         if(shuru.trim().isEmpty()){
             System.out.println("寄件人信息不能为空！");
         }else{
             user.setSender(shuru );
             break;
         }

     }

        for(;;){

            System.out.println("请输入寄件人信息：");
            String shuru=sc.next();
            if(shuru.trim().isEmpty()){
                System.out.println("取件人信息不能为空！");
            }else{
                user.setRecipients(shuru );
                break;
            }

        }

        System.out.println("请选择物品类型:1.日用品  2.食品  3.文件  4.衣物  5.数码产品  6.其他");

        int shuru= 0;
        try {
            shuru = sc.nextInt();
        } catch (Exception e) {
            e.printStackTrace();
        }

        switch (shuru){

            case 1:
                user.setItem("日用品");
                break;

            case 2:
                user.setItem("食品");
                break;

            case 3:
                user.setItem("文件");
                break;

            case 4:
                user.setItem("衣物");
                break;

            case 5:
                user.setItem("数码产品");
                break;

            case 6:
                user.setItem("其他");
                break;

            default:
                System.exit(0);//关闭虚拟机，程序停止运行
        }

      for(;;){

          System.out.println("请选择取件时间:  1. 9:00~13:00   2.14:00~19:00");
          int xz= 0;

          try {
              xz = sc.nextInt();
          } catch (Exception e) {
              e.printStackTrace();
          }

          if(xz==1){
              user.setTimer("9:00~13:00");
              break;
          }else if(xz==2){
              user.setTimer("14:00~19:00");
              break;
          }else{
              System.out.println("请输入正确选项！");
          }

      }

        System.out.println("请输入物品预估重量(kg):");
        int kg=0;
        try {
             kg=sc.nextInt();
        } catch (Exception e) {
            e.printStackTrace();
        }
        user.setWeight(kg);

        System.out.println("是否保价(y/n):");

        String bj="";
        try {
            bj=sc.next();
        } catch (Exception e) {
            e.printStackTrace();
        }

        if(bj.equals("y")){
            System.out.println("请输入所寄物品估价(单位:元 按0.5%支付保价费):");
            int bjf=0;
            try {
             bjf=sc.nextInt();
            } catch (Exception e) {
                e.printStackTrace();
            }
            user.setBaojia(bjf);
            CountServiceImpl countService=new CountServiceImpl();
            User user1=countService.count(user);
            list.add(user1);
            System.out.println("********寄件信息********");
        }

        return null;
    }

    //实现寄件类

}
